import request from '@/utils/request'
import type { PermissionResponseData, MenuParams } from './type'
enum API {
    // 获取菜单
    GETPERMISSION_URL = "/admin/acl/permission",
    // 给某一级添加一个子菜单
    ADDPERMISSION_URL = "/admin/acl/permission/save",
    // 给某一级修改子菜单
    UPDATEPERMISSION_URL = "/admin/acl/permission/update",
    // 删除菜单
    DELETEPERMISSION_URL = "/admin/acl/permission/remove/"
}
// 获取菜单
export const reqGetPermissionList = () => request.get<any, PermissionResponseData>(API.GETPERMISSION_URL)
// 修改或添加菜单
export const reqAddOrUpdatePermission = (data: MenuParams) => {
    if (data.id) {
        return request.put<any, any>(API.UPDATEPERMISSION_URL, data)
    } else {
        return request.post<any, any>(API.ADDPERMISSION_URL, data)
    }
}
// 删除某个菜单
export const reqDeletePermission = (id: number) => request.delete<any, any>(API.DELETEPERMISSION_URL + id)
